home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / RECORDS.SWG / 0012_Finding Records.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  896b  |  30 lines

  1. {
  2. > What is the best way to Find a record in a file of Records?
  3. > Can one seek to the specified record, or do you need to
  4. > read each record in the file and check a field for the
  5. > proper value?
  6.  
  7. If you want a search on one field, you better create a sorted index-file where
  8. you can search on a btree-kind of way.
  9.  
  10. Something like this:
  11. }
  12. RecFile : Record =
  13.              Deleted: Boolean;
  14.              Name   : String[15];
  15.              Descrip: String[25];
  16.              RText  : Array[0..39] of String[82];
  17.           End;
  18.  
  19. IdxFile : Record =
  20.              Name : String[15];  {same as in RecFile}
  21.              Recnum : Word;      {record.no. in RecFile}
  22.           End;
  23.  
  24. Var Rfile : File of RecFile;
  25.     Ifile : File of IdxFile;
  26. {
  27. If you keep your index-file sorted, you can search quikly for a name in the
  28. index and a Seek(Rfile, Ifile.Recnum) gives you the record.
  29. }
  30.